package com.decent.common.validator;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.Documented;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * 校验时间范围
 *
 * @author: wangyan
 * @date: 2021/12/16
 */
@Documented
@Retention(RUNTIME)
@Constraint(validatedBy = CheckTimeRangeValidator.class)
@Repeatable(CheckTimeRange.List.class)
@Target({METHOD, ANNOTATION_TYPE, CONSTRUCTOR, TYPE})
public @interface CheckTimeRange {

    String startTime() default "startTime";

    String endTime() default "endTime";

    int limitDays() default 30;

    String message() default "";

    Class<?>[] groups() default {};

    @SuppressWarnings("unused") Class<? extends Payload>[] payload() default {};

    /**
     * Defines several {@link CheckTimeRange} annotations on the same element.
     *
     * @see CheckTimeRange
     */
    @Documented
    @Retention(RUNTIME)
    @Target({METHOD, ANNOTATION_TYPE, CONSTRUCTOR, TYPE})
    @interface List {
        CheckTimeRange[] value();
    }

}
